package com.framework.controller.system;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.framework.annotation.SystemLog;
import com.framework.controller.index.BaseController;
import com.framework.entity.AfdcitytreeFormMap;
import com.framework.entity.ButtomFormMap;
import com.framework.entity.LogSMSFormMap;
import com.framework.entity.Params;
import com.framework.entity.factory.FormmapFactory;
import com.framework.entity.view.UserAccessoryViewFormMap;
import com.framework.mapper.AfdcitytreeMapper;
import com.framework.plugin.PageView;
import com.framework.util.Common;
import com.framework.util.TreeObject;
import com.framework.util.TreeUtil;
import com.framework.util.showLog.LogView;


/**
 * 
 * @author Lyon
 *
 *创建时间：2016年11月7日 下午2:16:18
 */
@Controller
@RequestMapping("/datalog/")
public class DatalogController extends BaseController {
	public final static String FILE_PATH="D:\\logger\\app.log";
	
	
	@RequestMapping("listUI")
	public String listUI() throws IOException {
		return Common.BACKGROUND_PATH + "/system/datalog/list";
	}
	
	
	
	@ResponseBody
	@RequestMapping("showLog")
	public String showLog() throws IOException {
		LogView logView=new LogView();
		File logFile=new File(FILE_PATH);
		String logDate=logView.delayShowLog(logFile);
		return logDate;
	}
	
	@RequestMapping("listEnFileUI")
	public String listEnFileUI() throws IOException {
		return Common.BACKGROUND_PATH + "/system/datalog/listEnFile";
	}
	
	@ResponseBody
	@RequestMapping("showEnFileLog")
	public PageView showEnFileLog(String draw, String length, String start) throws IOException, InstantiationException, IllegalAccessException {
		UserAccessoryViewFormMap userAccessoryViewFormMap=FormmapFactory.getBeanFormMap(UserAccessoryViewFormMap.class);
		userAccessoryViewFormMap = toFormMap(userAccessoryViewFormMap, draw, length, start);
		pageView=userAccessoryViewFormMap.findByPage_Names(pageView);
		return pageView;
	}
	
	
	@RequestMapping("listSMSUI")
	public String listSMSUI() throws IOException {
		return Common.BACKGROUND_PATH + "/system/datalog/listSMSLog";
	}
	
	@ResponseBody
	@RequestMapping("showSMSLog")
	public PageView showSMSLog(String draw, String length, String start) throws IOException, InstantiationException, IllegalAccessException {
		LogSMSFormMap logSMSFormMap=FormmapFactory.getBeanFormMap(LogSMSFormMap.class);
		logSMSFormMap = toFormMap(logSMSFormMap, draw, length, start);
		logSMSFormMap.put("$orderby", getKeyTimeOrder());
		logSMSFormMap.put("$search", getsearch());
		logSMSFormMap.put("keyCloumn",  getKeyCloumn());
		pageView=logSMSFormMap.findByPage_Names(pageView);
		return pageView;
	}
}